package org.platform.lwc.codegen;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.config.po.LikeTable;
import com.baomidou.mybatisplus.generator.config.rules.DateType;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

public class CodeGenServerApplication {


    /**
     * @param args 简单生成
     */
    public static void main(String[] args) {
        //生成system-service 服务代码
        system();

    }

    private static void system() {
//        String generatorPath = "D:/service-base/system-service/src/main/java";
        String generatorPath = System.getProperty("user.dir") + "/service-base/system-service/src/main/java";
        FastAutoGenerator.create("jdbc:mysql://42.192.22.180:3306/lwc-system", "root", "123456")
                .globalConfig(builder -> {
                    builder.author("lwc") // 设置作者
                            .fileOverride() // 覆盖已生成文件
                            .outputDir(generatorPath); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("org.platform.lwc") // 设置父包名
                            .moduleName("system") // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.xml, generatorPath+"/org/platform/lwc/system/mapper")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
//                    builder.addInclude("sys_post").addTablePrefix("sys_", "c_"); // 设置需要生成的表名  设置过滤表前缀
                    builder.entityBuilder().idType(IdType.ASSIGN_ID).enableLombok();
                    builder.controllerBuilder().enableRestStyle()
                    ;
                    builder.mapperBuilder().enableBaseResultMap().enableMapperAnnotation().enableBaseColumnList();
                })
                .templateEngine(new FreemarkerTemplateEngine())
                .execute();
    }


}
